<template>
<view class="container" :style="'height:' + (servantshowWay==1? '100%':'')"> 
<!-- 头部 -->
 <view class="typeSearchContainer" v-if="reqType!='order'"> 
    <view class="search_input_bg">
      <view class="search_input">
        <view class="search_input_left">
          <image class="input_img" src="https://image1.sansancloud.com/xianhua/2018_9/14/16/25/0_222.jpg?x-oss-process=style/preview_120"></image>
          <input class="input" @confirm="getSearchservantName" :value="servantName" placeholder="搜索人员名称"></input>
        </view>
      </view>
    </view>
    <!-- 筛选start -->
    <view class="zhezhao" v-if="showCount||showMoreSelectState" @tap="closeZhezhao"></view>
    <view class="select_top" :style="'position:' + (componentState?'relative':'fixed')">
      <view class="select_tab" v-if="selectTab.length!=0">
        <view class="select_tab_item" v-for="(selectTabItem, index) in selectTab" :key="index" v-if="index<=1" @click.stop="selectTabFun" :data-index="index">
          <text class="select_tab_item_text" :style="'color:' + (selectTabIndex==index||(selectResultsValue[selectTabItem.name]&&selectResultsValue[selectTabItem.name].length!=0&&(selectTabItem.type=='multi-select'||selectTabItem.type=='multistage-style'))?setting.platformSetting.defaultColor:'')">{{selectResultsValue[selectTabItem.name]&&selectTabItem.type=='pull-down'?selectResultsValue[selectTabItem.name]:selectTabItem.title}}</text>
          <image class="select_tab_item_icon" v-if="!selectTabItem.state" src="https://image1.sansancloud.com/jianzhan/2019_3/20/12/1/52_354.jpg?x-oss-process=style/preview_120"></image>
          <image class="select_tab_item_icon" v-else src="https://image1.sansancloud.com/jianzhan/2019_3/20/12/1/52_336.jpg?x-oss-process=style/preview_120"></image>
        </view>
        <!-- 下拉的选择样式 -->
        <scroll-view scroll-y class="select_tab_item_value" v-if="showCount&&selectTab[selectTabIndex].type=='pull-down'">
          <text class="select_tab_item_value_name" data-index="-1" @click.stop="selectResult">不限</text>
          <text class="select_tab_item_value_name" :data-index="index" @click.stop="selectResult" v-for="(selectTabItemValues, index) in selectTab[selectTabIndex].listValues" :key="index">{{selectTabItemValues.value}}</text>
        </scroll-view>
        <!-- 多选的选择样式 -->
        <view class="select_tab_item_value_two" v-if="showCount&&selectTab[selectTabIndex].type=='multi-select'">
          <scroll-view scroll-y class="select_tab_list_two_block">
            <text class="select_tab_item_value_name_two" data-index="-1" @click.stop="selectResult" :style="(!selectResultsValue[selectTab[selectTabIndex].name]||selectResultsValue[selectTab[selectTabIndex].name].length==0?'background:'+setting.platformSetting.defaultColor+';color:'+'#fff':'')">不限</text>
            <text class="select_tab_item_value_name_two" :data-index="index" :style="'background:' + (selectTabItemValues.state?setting.platformSetting.defaultColor:'') + ';color:' + (selectTabItemValues.state?'#fff':'')" @click.stop="selectResult" v-for="(item, index) in selectTab[selectTabIndex].listValues" :key="index">{{selectTabItemValues.value}}</text>
          </scroll-view>
          <view class="multi_select_bg">
            <text class="multi_select_btn_clear" @click.stop="clearSelect" :style="'color:' + setting.platformSetting.defaultColor + ';border:1rpx solid ' + setting.platformSetting.defaultColor">重置</text>
            <text class="multi_select_btn" @click.stop="sureSelect" :style="'background:' + setting.platformSetting.defaultColor + ';border:1rpx solid ' + setting.platformSetting.defaultColor">确定</text>
          </view>
        </view>
        <!-- 级联的选择样式 -->
        <view class="select_tab_item_value_four" v-if="showCount&&selectTab[selectTabIndex].type=='multistage-style'">
          <view class="select_tab_list_four_list">
            <!-- 一级 -->
            <scroll-view scroll-y class="select_tab_list_four_block">
              <text class="select_tab_item_value_name_four" data-level="two" data-index="-1" @click.stop="selectResult" :style="'border-bottom:' + (!selectResultsValue[selectTab[selectTabIndex].name]||selectResultsValue[selectTab[selectTabIndex].name].length==0?'1rpx solid '+setting.platformSetting.defaultColor:'') + ';background:' + (!selectResultsValue[selectTab[selectTabIndex].name]||selectResultsValue[selectTab[selectTabIndex].name].length==0?'#fff':'') + ';color:' + (!selectResultsValue[selectTab[selectTabIndex].name]||selectResultsValue[selectTab[selectTabIndex].name].length==0?setting.platformSetting.defaultColor:'')">不限</text>
              <text class="select_tab_item_value_name_four" :data-index="index" :style="'border-bottom:' + (selectTabItemValues.state?'1rpx solid '+setting.platformSetting.defaultColor:'') + ';background:' + (selectTabItemValues.state?'#fff':'') + ';color:' + (selectTabItemValues.state?setting.platformSetting.defaultColor:'')" @click.stop="selectResult" v-for="(item, index) in selectTab[selectTabIndex].listValues" :key="index" :data-item="selectTabItemValues" data-level="two">{{selectTabItemValues.name}}</text>
            </scroll-view>
            <!-- 二级 -->
            <scroll-view scroll-y class="select_tab_list_four_block">
              <text class="select_tab_item_value_name_four" data-index="-1" data-level="three" @click.stop="selectResult" :style="'border-bottom:' + (!selectResultsValue[selectTab[selectTabIndex].name]||selectResultsValue[selectTab[selectTabIndex].name].length==1?'1rpx solid '+setting.platformSetting.defaultColor:'') + ';background:' + (!selectResultsValue[selectTab[selectTabIndex].name]||selectResultsValue[selectTab[selectTabIndex].name].length==1?'#fff':'') + ';color:' + (!selectResultsValue[selectTab[selectTabIndex].name]||selectResultsValue[selectTab[selectTabIndex].name].length==1?setting.platformSetting.defaultColor:'')">不限</text>
              <text class="select_tab_item_value_name_four" :data-index="index" :style="'border-bottom:' + (selectTabItemValues.state?'1rpx solid '+setting.platformSetting.defaultColor:'') + ';background:' + (selectTabItemValues.state?'#fff':'') + ';color:' + (selectTabItemValues.state?setting.platformSetting.defaultColor:'')" @click.stop="selectResult" v-for="(item, index) in twoMultistageData[selectTab[selectTabIndex].name]" :key="index" data-level="three" :data-item="selectTabItemValues" v-if="twoMultistageData[selectTab[selectTabIndex].name]">{{selectTabItemValues.name}}</text>
            </scroll-view>
            <!-- 三级 -->
            <scroll-view scroll-y class="select_tab_list_four_block">
              <text class="select_tab_item_value_name_four" data-index="-1" @click.stop="selectResult" :style="'border-bottom:' + (!selectResultsValue[selectTab[selectTabIndex].name]||selectResultsValue[selectTab[selectTabIndex].name].length==1||selectResultsValue[selectTab[selectTabIndex].name].length==2?'1rpx solid '+setting.platformSetting.defaultColor:'') + ';background:' + (!selectResultsValue[selectTab[selectTabIndex].name]||selectResultsValue[selectTab[selectTabIndex].name].length==1||selectResultsValue[selectTab[selectTabIndex].name].length==2?'#fff':'') + ';color:' + (!selectResultsValue[selectTab[selectTabIndex].name]||selectResultsValue[selectTab[selectTabIndex].name].length==1||selectResultsValue[selectTab[selectTabIndex].name].length==2?setting.platformSetting.defaultColor:'')">不限</text>
              <text class="select_tab_item_value_name_four" :data-index="index" :style="'border-bottom:' + (selectTabItemValues.state?'1rpx solid '+setting.platformSetting.defaultColor:'') + ';background:' + (selectTabItemValues.state?'#fff':'') + ';color:' + (selectTabItemValues.state?setting.platformSetting.defaultColor:'')" @click.stop="selectResult" v-for="(item, index) in threeMultistageData[selectTab[selectTabIndex].name]" :key="index" :data-item="selectTabItemValues" v-if="threeMultistageData[selectTab[selectTabIndex].name]">{{selectTabItemValues.name}}</text>
            </scroll-view>
          </view>
          <!-- 按钮 -->
          <view class="multi_select_bg">
            <text class="multi_select_btn_clear" @click.stop="clearSelect" :style="'color:' + setting.platformSetting.defaultColor + ';border:1rpx solid ' + setting.platformSetting.defaultColor">重置</text>
            <text class="multi_select_btn" @click.stop="sureSelect" :style="'background:' + setting.platformSetting.defaultColor + ';border:1rpx solid ' + setting.platformSetting.defaultColor">确定</text>
          </view>
        </view>
        <!--更多筛选的样式  -->
        <view class="select_tab_list_three" v-if="showMoreSelectState">
          <scroll-view scroll-y class="select_tab_list_three_block">
            <view class="select_tab_item_three" v-for="(selectTabItem, indexOne) in selectTab" :key="indexOne" v-if="indexOne>1&&selectTabItem.type!='multistage-style'">
              <view class="select_tab_item_three_title">
                <text>{{selectTabItem.title}}</text>
                <text style="color:#ccc;margin-left:6rpx" v-if="selectTabItem.type=='pull-down'">(单选)</text>
                <text style="color:#ccc;margin-left:6rpx" v-if="selectTabItem.type=='multi-select'">(可多选)</text>
              </view>
              <view class="select_tab_item_three_value_list">
                <view class="select_tab_item_value_name_three" :data-father="indexOne" data-index="-1" :style="(!selectResultsValue[selectTabItem.name]||selectResultsValue[selectTabItem.name].length==0?'background:'+setting.platformSetting.defaultColor+';color:'+'#fff':'')" @click.stop="selectResult">
                  <text>不限</text>
                </view>
                <view class="select_tab_item_value_name_three" :data-father="indexOne" data-type="more_select" :data-index="index" :style="'background:' + (selectTabItemValues.state?setting.platformSetting.defaultColor:'') + ';color:' + (selectTabItemValues.state?'#fff':'')" @click.stop="selectResult" v-for="(selectTabItemValues, indexNaN) in selectTabItem.listValues" :key="indexNaN">
                  <!-- <text wx:if="{{selectTabItem.type=='pull-down'}}">{{selectTabItemValues}}</text> -->
                  <text>{{selectTabItemValues.value}}</text>
                </view>
              </view>
            </view>
          </scroll-view>
          <view class="multi_select_bg">
            <text class="multi_select_btn_clear" @click.stop="clearSelect" :style="'color:' + setting.platformSetting.defaultColor + ';border:1rpx solid ' + setting.platformSetting.defaultColor">重置</text>
            <text class="multi_select_btn" @click.stop="sureSelect" :style="'background:' + setting.platformSetting.defaultColor + ';border:1rpx solid ' + setting.platformSetting.defaultColor">确定</text>
          </view>
        </view>
        <!-- 更多筛选按钮 -->
        <view class="more_select" v-if="selectTab.length>2" @click.stop="moreSelectFun">
          <image class="more_select_icon" src="https://image1.sansancloud.com/sansancloud/2019_7/10/10/48/52_267.jpg?x-oss-process=style/preview_120"></image>
          <text class="more_select_text">筛选</text>
        </view>
      </view>
      <!-- 更多筛选按钮 -->
      <view class="more_select" @click.stop="moreSelectFun">
        <image class="more_select_icon" src="https://image1.sansancloud.com/sansancloud/2019_7/10/10/48/52_267.jpg?x-oss-process=style/preview_120"></image>
        <text class="more_select_text">筛选</text>
      </view>
    </view>
    <!-- 筛选end -->
  </view>
  
  <servant-list-component id="servantList" v-if="options" :receiveData="options" :params="params" :reqType="reqType"></servant-list-component>
</view>
</template>

<script>

export default {
  data() {
    return {
      setting: null,
      // setting   
      servantData: null,
      // 商品数据 
      servantType: [],
      // 商品数据 
      servantshowWay: 2,
      servantName:'',
      // servantshowWay列表显示方法 (默认显示地图)
      colorAtive: '#888',
      selectTab: [{
        title: '全部分类',
        type: 'pull-down',
        name: 'servantTypeId',
        state: false,
        value: '',
        listValues: []
      }, {
        title: '默认排序',
        value: '',
        type: 'pull-down',
        name: '默认排序',
        state: false,
        listValues: []
      }],
      selectTabIndex: -1,
      selectResultsValue: {},
      selectResultsObj: {},
      reqType: "",

      /* 全部参数 */
      params: {
        page: 1,
        latitude: '0',
        longitude: '0',
        servantName: "",
        servantTypeId: 0,
        mendianId: 0
      },
      showCount: false,
      showMoreSelectState: false,
      threeMultistageData: "",
      twoMultistageData: "",
      servantDetail: "",
      selectServant: "",
      options: "",
      properties: "",
      currentType:null,
      componentState:false
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    console.log("options", options);
    if (options.reqType) {
      that.setData({
        reqType: options.reqType
      });
    }
    options.androidTemplate = "typeOne";
    that.setData({
      options: options,
      setting: getApp().globalData.setting
    });
    that.getServantType(options.servantTypeId);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    let that = this;
    that.mapCtx = wx.createMapContext('map');
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    let that = this;
    that.setData({
      searchOrganizesName: ""
    });
    that.selectComponent("#servantList").pullDownRefreshFun();
    wx.hideNavigationBarLoading(); //完成停止加载
    wx.stopPullDownRefresh(); //停止下拉刷新
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    var that = this;
    that.selectComponent("#servantList").reachBottomFun();
  },
  methods: {
    calling: function (e) {
      let that = this;
      console.log("======calling======", e);
      let telno = e.currentTarget.dataset.telno;
      console.log("========telno========", telno);
      getApp().globalData.calling(telno);
    },
    selectTabFun: function (e) {
      console.log("====selectTab====", e);
      let that = this;
      that.closeZhezhao();
      let selectTab = that.selectTab;
      let index = e.currentTarget.dataset.index;

      if (that.selectTabIndex != index) {
        that.setData({
          showCount: true,
          showMoreSelectState: false
        });
        that.setData({
          selectTabIndex: index
        });

        for (let i = 0; i < selectTab.length; i++) {
          selectTab[i].state = false;
        }

        that.selectTab[index].state = true;
        that.setData({
          selectTab: selectTab
        });
      } else {
        that.closeZhezhao();
      }
    },
    closeZhezhao: function () {
      let that = this;
      let selectTab = that.selectTab;
      that.setData({
        selectTabIndex: -1
      });

      for (let i = 0; i < selectTab.length; i++) {
        selectTab[i].state = false;
      }

      that.setData({
        showCount: false,
        showMoreSelectState: false,
        selectTab: selectTab
      });
    },
    selectResult: function (e) {
      let that = this;
      console.log("===selectResult===", e);
      let index = e.currentTarget.dataset.index; //选项的位置

      let type = e.currentTarget.dataset.type; //选项的类型

      let indexFather = e.currentTarget.dataset.father; //tab的位置(更多里面点击时传的)

      let selectTabIndex = indexFather || that.selectTabIndex; //tab的位置

      let selectTab = that.selectTab; //tab数据

      let params = that.params; //搜索数据

      let selectResultsValue = that.selectResultsValue; //搜索数据

      if (selectTab[selectTabIndex].type == 'pull-down') {
        if (index == -1) {
          console.log("======pull-down选择了全部=====");
          selectResultsValue[selectTab[selectTabIndex].name] = "";
          params[selectTab[selectTabIndex].name] = 0;
        } else {
          console.log("======pull-down选择了其他选项=====");
          selectResultsValue[selectTab[selectTabIndex].name] = selectTab[selectTabIndex].listValues[index].value;
          params[selectTab[selectTabIndex].name] = selectTab[selectTabIndex].listValues[index].id;

          for (let i = 0; i < selectTab[selectTabIndex].listValues.length; i++) {
            selectTab[selectTabIndex].listValues[i].state = false;
          }

          selectTab[selectTabIndex].listValues[index].state = true;
        }

        if (!type && type != 'more_select') {
          that.closeZhezhao();
          that.selectComponent("#servantList").getData(params,2);
        }
      } else if (selectTab[selectTabIndex].type == 'multi-select') {
        if (index == -1) {
          console.log("======multi-select选择了全部=====");
          params[selectTab[selectTabIndex].name] = 0;
          selectResultsValue[selectTab[selectTabIndex].name] = "";

          for (let i = 0; i < selectTab[selectTabIndex].listValues.length; i++) {
            selectTab[selectTabIndex].listValues[i].state = false;
          }
        } else {
          console.log("======multi-select选择了其他选项=====");
          let resultData = [];

          if (params[selectTab[selectTabIndex].name]) {
            resultData = params[selectTab[selectTabIndex].name];
          }

          if (!selectTab[selectTabIndex].listValues[index].state) {
            resultData.push(selectTab[selectTabIndex].listValues[index].value);
          } else {
            for (let i = 0; i < resultData.length; i++) {
              if (resultData[i] == selectTab[selectTabIndex].listValues[index].value) {
                resultData.splice(i, 1);
              }
            }
          }

          params[selectTab[selectTabIndex].name] = resultData;
          selectTab[selectTabIndex].listValues[index].state = selectTab[selectTabIndex].listValues[index].state ? false : true;
        }
      } else if (selectTab[selectTabIndex].type == 'multistage-style') {
        //级联
        let level = e.currentTarget.dataset.level; //选项的级别;

        let itemData = e.currentTarget.dataset.item; //选项的数据;

        let allTwoMultistageData = that.twoMultistageData;
        let allThreeMultistageData = that.threeMultistageData; // let twoMultistageData
        // let threeMultistageData

        let resultData = params[selectTab[selectTabIndex].name];

        if (index == -1) {
          console.log("======multistage-style选择了全部=====");

          if (level == "two") {
            console.log("====two-1====");
            allTwoMultistageData[selectTab[selectTabIndex].name] = null;
            allThreeMultistageData[selectTab[selectTabIndex].name] = null;
            resultData = "";

            for (let i = 0; i < selectTab[selectTabIndex].listValues.length; i++) {
              selectTab[selectTabIndex].listValues[i].state = false;
            }
          } else if (level == "three") {
            console.log("====three-1====");
            allThreeMultistageData[selectTab[selectTabIndex].name] = null;
            console.log("====resultData===", resultData);

            if (resultData.length == 3) {
              resultData.splice(2, 1);
            }

            if (resultData.length == 2) {
              resultData.splice(1, 1);
            }

            if (allTwoMultistageData[selectTab[selectTabIndex].name] && allTwoMultistageData[selectTab[selectTabIndex].name].length != 0) {
              for (let i = 0; i < allTwoMultistageData[selectTab[selectTabIndex].name].length; i++) {
                allTwoMultistageData[selectTab[selectTabIndex].name][i].state = false;
              }
            } // threeMultistageData = null

          } else {
            console.log("====three-2====");

            if (resultData.length == 3) {
              resultData.splice(2, 1);
            }

            if (allThreeMultistageData[selectTab[selectTabIndex].name] && allThreeMultistageData[selectTab[selectTabIndex].name].length != 0) {
              for (let i = 0; i < allThreeMultistageData[selectTab[selectTabIndex].name].length; i++) {
                allThreeMultistageData[selectTab[selectTabIndex].name][i].state = false;
              }
            }
          }
        } else {
          console.log("======multi-select选择了其他选项=====");

          if (level == "two") {
            console.log("====显示two，点击one===="); // twoMultistageData = itemData.children

            allTwoMultistageData[selectTab[selectTabIndex].name] = itemData.children;

            for (let i = 0; i < selectTab[selectTabIndex].listValues.length; i++) {
              selectTab[selectTabIndex].listValues[i].state = false;
            }

            selectTab[selectTabIndex].listValues[index].state = true;

            if (!resultData) {
              resultData = [];
            }

            resultData.splice(0, 1, itemData.name); // threeMultistageData = null

            allThreeMultistageData[selectTab[selectTabIndex].name] = null;
            resultData.splice(2, 1);
            resultData.splice(1, 1);
          } else if (level == "three") {
            console.log("====显示three，点击two===="); // threeMultistageData = itemData.children

            allThreeMultistageData[selectTab[selectTabIndex].name] = itemData.children;

            for (let i = 0; i < allTwoMultistageData[selectTab[selectTabIndex].name].length; i++) {
              allTwoMultistageData[selectTab[selectTabIndex].name][i].state = false;
            }

            allTwoMultistageData[selectTab[selectTabIndex].name][index].state = true;
            resultData.splice(1, 1, itemData.name);
            resultData.splice(2, 1);
          } else {
            console.log("====点击three====");

            for (let i = 0; i < allThreeMultistageData[selectTab[selectTabIndex].name].length; i++) {
              allThreeMultistageData[selectTab[selectTabIndex].name][i].state = false;
            }

            allThreeMultistageData[selectTab[selectTabIndex].name][index].state = true;
            resultData.splice(2, 1, itemData.name);
          }
        }

        params[selectTab[selectTabIndex].name] = resultData;
        console.log("==threeMultistageData===", allThreeMultistageData, allTwoMultistageData);
        that.params = params;
        that.setData({
          threeMultistageData: allThreeMultistageData,
          twoMultistageData: allTwoMultistageData,
          params: params,
          selectResultsValue: selectResultsValue
        });
      }

      that.params = params;
      console.log("==params===", params);
      that.setData({
        params: params,
        selectTab: selectTab,
        selectResultsValue: selectResultsValue
      });
    },
    //获取产品分类
    getServantType: function (servantTypeId) {
      var customIndex = getApp().globalData.AddClientUrl("/find_servant_types.html"); // wx.showLoading({
      //   title: 'loading'
      // })

      getApp().globalData.showToastLoading('loading', true);
      var that = this;
      wx.request({
        url: customIndex.url,
        header: getApp().globalData.header,
        success: function (res) {
          wx.hideLoading();
          console.log("getServantType", res.data);

          if (res.data.errcode == 0) {
            let resultData = res.data.relateObj.result;

            for (let i = 0; i < resultData.length; i++) {
              resultData[i].value = resultData[i].name;
              resultData[i].state = false;
            }

            console.log("========resultData=========", resultData);
            that.selectTab[0].listValues = resultData;
            that.setData({
              servantType: resultData,
              selectTab: that.selectTab
            });
          } else {
            that.setData({
              servantType: that.servantType
            });
          } // that.data.servantType.unshift({ id: servantTypeId || 0, name: "全部" })


          for (let i = 0; i < that.servantType.length; i++) {
            that.servantType[i].colorAtive = '#888';
          }

          that.servantType[0].colorAtive = that.setting.platformSetting.defaultColor;
          that.servantType[0].active = true;
          that.setData({
            servantType: that.servantType,
            currentType: that.servantType[0]
          });
          wx.hideLoading();
        },
        fail: function (res) {
          console.log("fail");
          wx.hideLoading();
          getApp().globalData.loadFail();
        }
      });
    },

    /* 点击分类大项 */
    bindTypeItem: function (event) {
      console.log(event);
      let that = this;
      let onId;
      that.hiddenProInfo();

      if (event && event.currentTarget) {
        onId = event.currentTarget.dataset.type.id;
        console.log('====bindTypeItem currentTarget====', onId);
      } else if (event && !event.currentTarget) {
        onId = event;
        console.log('====bindTypeItem event====', onId);
      }

      if(that.servantType.length!=0){
          for (let i = 0; i < that.servantType.length; i++) {
            if (that.servantType[i].id == onId) {
              that.servantType[i].active = true;
              console.log(that.setting.platformSetting.defaultColor);
              that.servantType[i].colorAtive = that.setting.platformSetting.defaultColor;
              that.setData({
                currentType: that.servantType[i]
              });
            } else {
              that.servantType[i].active = false;
              that.servantType[i].colorAtive = '#888';
              that.setData({
                currentType: that.servantType[i]
              });
            }
          }
      }

      that.setData({
        servantType: that.servantType
      });
      that.listPage.page = 1;
      that.params.page = 1;
      that.params.servantTypeId = onId;
      that.getServantData(that.params, 2);
      console.log("===currentType===", that.currentType);
    },
    getSearchservantName: function (e) {
        console.log(e);
        var that = this;
        if (e.detail.value) {
          that.params.servantName = e.detail.value;
        } else {
          that.params.servantName = '';
        }
        that.setData({
          servantName: that.params.servantName
        });
        that.selectComponent("#servantList").getSearchName(that.params);
    },
    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    }
  }
};
</script>
<style scoped>
@import "./index.css";
</style>